// xc_lshop/shop/deposit/record/access.js
var actdepositbill = require('../../model/deposit_bill')

Page({
  mixins: [require('../../../../xc/mixins/basicMixin')],

  /**
   * 页面的初始数据
   */
  data: {
    opactive:0,
    uid:-1,
    sendstatus:{
      '-1':{
        color:"#999999",
        name:"已取消"
      },
      '1':{
        color:"#ee0a24",
        name:"申请中"
      },
      '2':{
        color:"#07c160",
        name:"已核销"
      },
    }
  },
  showqr(item){
    this.selectComponent("#qrcode").init(item.op,item)
  },
  onopChange(e){
    console.log(e)
   this.setData({
    opactive:e.detail.index
   })
   var that=this;
   that.getpagelist(that,1)
  },
  getpagelist(that, rest, strwhere) {
    if(!strwhere){
      var strwhere={}
      strwhere['uid']=that.data.uid
      strwhere['opactive']=that.data.opactive
    }
    if (rest == 1) {
      that.setData({
        modellist: []
      });
    }
    actdepositbill.offset(that, rest, strwhere).then(function (result) {
      var updatemdoel = {};

      if ((result["code"] == "over" && result["obj"]) || result["code"] == "loadmore") {
        if (rest == 1) {
          updatemdoel["modellist"] = result["obj"]["modellist"];
        } else {
          if (result["obj"]["modellist"].length > 0) {
            updatemdoel["modellist"] = that.data.addrlist.concat(result["obj"]["modellist"]);
          }
        }
      }
      that.setData(updatemdoel);
    })
    return;
  },
  xcloaddata: function (options, config) {
    var that=this;
    if (config.deposit && config.deposit.status == 1) {
      var update={}
      if(options.uid){
        update['uid']=options.uid
      }
      if(options.opactive){
        update['opactive']=options.opactive * 1
      }
      this.setData(update)
      this.getpagelist(that,1)
    } else {
      this.error("寄存功能未开启", true)
    }
  },
  afterlogin: function (options, config, userinfo) {
    // var that = this;
    // var update = {}
    // if (userinfo['member_id'] != 0 && !this.data.uid) {
    //   update['uid']=userinfo['member_id']
    // }
    // that.setData(
    //   update
    // )
    // that.getpagelist(that,1)

  },
  
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {
    var that=this;
    that.getpagelist(that,-1)
  },
})